unit Unit5;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxStyles, cxCustomData, cxFilter, cxData,
  cxDataStorage, cxEdit, Data.DB, cxDBData, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid,
  Vcl.ExtCtrls, DBAccess, Uni, MemDS, Vcl.StdCtrls, Datasnap.DBClient, cxImage,Jpeg,
  cxGridCardView, cxGridDBCardView, cxGridCustomLayoutView;

type
  TForm5 = class(TForm)
    cxGrid1: TcxGrid;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    Panel1: TPanel;
    UniQuery1: TUniQuery;
    UniQuery1lsh: TIntegerField;
    UniQuery1wz: TStringField;
    UniQuery1yplx: TStringField;
    UniQuery1ypzy: TStringField;
    UniQuery1ypdq: TStringField;
    UniQuery1sysj: TStringField;
    UniQuery1gxsj: TStringField;
    UniQuery1jqjs: TStringField;
    UniQuery1wjlx: TStringField;
    UniQuery1wjrl: TStringField;
    UniQuery1msk: TStringField;
    UniQuery1qxcd: TStringField;
    UniQuery1zz: TStringField;
    UniQuery1http: TStringField;
    UniQuery1qvod: TStringField;
    UniQuery1m_pic: TStringField;
    UniQuery1f_pic: TStringField;
    UniQuery1ypmc: TStringField;
    UniQuery1url: TStringField;
    Button1: TButton;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    Button2: TButton;
    Button3: TButton;
    Label1: TLabel;
    ClientDataSet1lsh: TIntegerField;
    ClientDataSet1url: TStringField;
    ClientDataSet1http: TStringField;
    ClientDataSet1qvod: TStringField;
    ClientDataSet1m_pic: TStringField;
    cxGrid1DBTableView1lsh: TcxGridDBColumn;
    cxGrid1DBTableView1url: TcxGridDBColumn;
    cxGrid1DBTableView1http: TcxGridDBColumn;
    cxGrid1DBTableView1qvod: TcxGridDBColumn;
    cxGrid1DBTableView1m_pic: TcxGridDBColumn;
    cxGrid1DBTableView1image: TcxGridDBColumn;
    ClientDataSet1image: TBlobField;
    cxGrid1Level2: TcxGridLevel;
    cxGrid1DBCardView1: TcxGridDBCardView;
    ClientDataSet1ypmc: TStringField;
    DataSource2: TDataSource;
    cxGrid1DBCardView1m_image: TcxGridDBCardViewRow;
    UniQuery1m_pic_flag: TIntegerField;
    UniQuery1m_image: TBlobField;
    Button4: TButton;
    cxGrid1DBCardView1lsh: TcxGridDBCardViewRow;
    cxGrid1DBCardView1wz: TcxGridDBCardViewRow;
    cxGrid1DBCardView1yplx: TcxGridDBCardViewRow;
    cxGrid1DBCardView1ypzy: TcxGridDBCardViewRow;
    cxGrid1DBCardView1ypdq: TcxGridDBCardViewRow;
    cxGrid1DBCardView1sysj: TcxGridDBCardViewRow;
    cxGrid1DBCardView1gxsj: TcxGridDBCardViewRow;
    cxGrid1DBCardView1jqjs: TcxGridDBCardViewRow;
    cxGrid1DBCardView1wjlx: TcxGridDBCardViewRow;
    cxGrid1DBCardView1wjrl: TcxGridDBCardViewRow;
    cxGrid1DBCardView1msk: TcxGridDBCardViewRow;
    cxGrid1DBCardView1qxcd: TcxGridDBCardViewRow;
    cxGrid1DBCardView1zz: TcxGridDBCardViewRow;
    cxGrid1DBCardView1http: TcxGridDBCardViewRow;
    cxGrid1DBCardView1qvod: TcxGridDBCardViewRow;
    cxGrid1DBCardView1m_pic: TcxGridDBCardViewRow;
    cxGrid1DBCardView1f_pic: TcxGridDBCardViewRow;
    cxGrid1DBCardView1ypmc: TcxGridDBCardViewRow;
    cxGrid1DBCardView1url: TcxGridDBCardViewRow;
    cxGrid1DBCardView1m_pic_flag: TcxGridDBCardViewRow;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    page:integer;
  public
    { Public declarations }
  end;

var
  Form5: TForm5;

implementation

{$R *.dfm}

uses Unit1, Unit6;

procedure TForm5.Button1Click(Sender: TObject);
begin
  page:=page-1;
  UniQuery1.Close;
  UniQuery1.SQL.Clear;
  UniQuery1.SQL.Add('select * from info where m_pic_flag is not null Limit 8 Offset '+inttostr((page)*8) ) ;
  UniQuery1.Open;
end;

procedure TForm5.Button2Click(Sender: TObject);
var
i:integer;
ms:TMemoryStream;
url:string;
jpg:   TJpegImage;
        bmp:   TBitmap;
begin
//  ClientDataSet1.Active:=false;
//  ClientDataSet1.CreateDataSet;

//  for I := 0 to 15 do
//  begin
//
//     ClientDataSet1.Append;
//     ClientDataSet1.FieldByName('lsh').AsString:=UniQuery1.FieldByName('lsh').AsString;
//     ClientDataSet1.FieldByName('url').AsString:=UniQuery1.FieldByName('url').AsString;
//     ClientDataSet1.FieldByName('http').AsString:=UniQuery1.FieldByName('http').AsString;
//     ClientDataSet1.FieldByName('qvod').AsString:=UniQuery1.FieldByName('qvod').AsString;
//     ClientDataSet1.FieldByName('m_pic').AsString:=UniQuery1.FieldByName('m_pic').AsString;
//     ClientDataSet1.FieldByName('ypmc').AsString:=UniQuery1.FieldByName('ypmc').AsString;
////      ms:= TMemoryStream.Create;
////      url:=StringReplace(UniQuery1.FieldByName('url').AsString,'about:/view/','',[]);
////      if FileExists('pic\977zy\'+url+'.jpg') then
////      begin
////        //ms.LoadFromFile('pic\977zy\'+url+'.jpg');
////         bmp   :=   TBitmap.Create;
////         jpg   :=   TJpegImage.Create;
////        jpg.LoadFromFile('pic\977zy\'+url+'.jpg');
////        bmp.Assign(jpg);
////        bmp.SaveToStream(ms);
////        TBlobField(ClientDataSet1.FieldByName('image')).LoadFromStream(ms);
////         bmp.Free;
////        jpg.Free
////
////      end;
//
//    //  ClientDataSet1.FieldByName('image').as
//
//     UniQuery1.Next;
//  end;

  page:=page+1;
  UniQuery1.Close;
  UniQuery1.SQL.Clear;
  UniQuery1.SQL.Add('select * from info where m_pic_flag is not null Limit 8 Offset '+inttostr(page*8) ) ;
  UniQuery1.Open;

end;

procedure TForm5.Button4Click(Sender: TObject);
  var
url:string;
begin
   url:=UniQuery1.FieldByName('qvod').AsString;
   try
      form6:=TForm6.Create(nil);
      Form6.url:=url;
      Form6.ShowModal;
   finally
     Form6.Free;
   end;
end;

procedure TForm5.FormShow(Sender: TObject);
begin
page:=0;
end;

end.
